package com.cqc.manage.error;

public enum ErrorEnum {

    DI_NOT_NULL("F001","编号不可为空",false),
    USER_NOT_FIND("F002","用户不存在",false),
    LACK_USER_ACCOUNT("F003","缺少账号",false),
    LACK_USER_USERNAME("F004","缺少用户名",false),
    LACK_USER_USERPASSWORD("F005","缺少用户密码",false),
    USER_STATUS_FALSE("F006","用户已被锁定",false),
    ROLE_NAME_EXIST("R001","角色名存在",false),
    UNKNOWN("999","未知异常",false),
    USER_EXIST("U001","用户已存在",false),
    NOPERMISSION("P001","没有权限",false);
    private String code;
    private String message;
    private boolean canRetry;

    ErrorEnum(String code,String message,boolean canRetry){
        this.code = code;
        this.message = message;
        this.canRetry = canRetry;
    }

    public static ErrorEnum getByCode(String code){
        for (ErrorEnum errorEnum: ErrorEnum.values()){
            if (errorEnum.code.equals(code)){
                return errorEnum;
            }
        }
        return UNKNOWN;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public boolean isCanRetry() {
        return canRetry;
    }

    public void setCanRetry(boolean canRetry) {
        this.canRetry = canRetry;
    }
}
